home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Composite_Alpha.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  3.9 KB  |  159 lines

  1. /*
  2. ** $VER: Composite_Alpha.ieb 1.2, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten 
  5. ** 24/1 1997 Stockholm/Sweden
  6. **
  7. ** Mix two images into one using alpha image.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK S2 A2'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.   
  41.   Xoff=0 ; Yoff=0
  42.   
  43.   if command ~= '' then parse var command Xoff Yoff '#'CalcType
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Composite" " OK | Cancel"',
  48.   ' INTEGER,"X offset",-4096,4096,'Xoff',SLIDER',
  49.   ' INTEGER,"Y offset",-4096,4096,'Yoff',SLIDER'
  50.  
  51.   if command = '' then do  
  52.     form = form||' CHECKBOX,"Stretch alpha to fit primary?",1'
  53.     
  54.     form
  55.     parse var result ok Xoff Yoff CalcType
  56.     if ok = 0 then return '<ERROR>'
  57.   end
  58.   else do
  59.     form
  60.     parse var result ok Xoff Yoff
  61.     if ok = 0 then return '<ERROR>'
  62.  
  63.     CalcType = 'none'
  64.   end
  65.  
  66.   back = Xoff Yoff '#'CalcType
  67. return back
  68.  
  69. /* Required "Process_image" procedure  ------------------------------- */
  70.  
  71. process_image:
  72.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'sec_image'"' '"'alp_image'"'
  73.   parse var options Xoff Yoff '#'CalcType
  74.  
  75.   'OPEN' '"'src_image'"' '24'
  76.   if (RC ~= 0) then do
  77.     'IE_TO_FRONT'
  78.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  79.     return '<ERROR>'
  80.   end
  81.   else LoadImage = result
  82.  
  83.   'OPEN' '"'sec_image'"' '24'
  84.   if (RC ~= 0) then do
  85.     'IE_TO_FRONT'
  86.     'REQUEST' '"Failed to load secondary image:' d2c(10)||sec_image'"' '" OK "'
  87.     return '<ERROR>'
  88.   end
  89.   else SecondImage = result
  90.  
  91.   'OPEN' '"'alp_image'"' '8'
  92.   if (RC ~= 0) then do
  93.     'IE_TO_FRONT'
  94.     'REQUEST' '"Failed to load alpha image:' d2c(10)||alp_image'"' '" OK "'
  95.     return '<ERROR>'
  96.   end
  97.   else AlphaImage = result
  98.  
  99.   'PROJECT_INFO' LoadImage 'WIDTH'
  100.   IW = RESULT
  101.   'PROJECT_INFO' LoadImage 'HEIGHT'
  102.   IH = RESULT
  103.  
  104.   'PROJECT_INFO' SecondImage 'WIDTH'
  105.   SIW = RESULT
  106.   'PROJECT_INFO' SecondImage 'HEIGHT'
  107.   SIH = RESULT
  108.  
  109.   if Xoff > SIW then Xoff = SIW
  110.   if Yoff > SIH then Yoff = SIH
  111.   
  112.   if Xoff < (-1)*IW then Xoff = (-1)*IW
  113.   if Yoff < (-1)*IH then Hoff = (-1)*IH
  114.  
  115.   'MARK' LoadImage 'PRIMARY'
  116.   'MARK' SecondImage 'SECONDARY'
  117.   'MARK' AlphaImage 'ALPHA'
  118.  
  119.   if CalcType=1 then CalcType='STRETCH'
  120.   else CalcType=''
  121.  
  122.   'COMPOSITE' Xoff Yoff 'ALPHA' CalcType
  123.   OutputImage = result
  124.   'CLOSE' LoadImage
  125.   'CLOSE' SecondImage
  126.   'CLOSE' AlphaImage
  127.  
  128.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  129.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  130.   if (RC ~= 0) then do
  131.     'IE_TO_FRONT'
  132.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  133.     return '<ERROR>'
  134.   end
  135.   'CLOSE' OutputImage
  136.  
  137.   back = 'OK'
  138. return back
  139.  
  140. /* Internal procedures  ---------------------------------------------- */
  141.  
  142. /*******************************************************************/
  143. /* This is where control goes when an error code is returned by IE */
  144. /* It puts up a message saying what happened and on which line     */
  145. /*******************************************************************/
  146. error:
  147. if RC=5 then do            /* Did the user just cancel us? */
  148.     IE_TO_FRONT
  149.     LAST_ERROR
  150.     'REQUEST "'||RESULT||'"'
  151. end
  152. else do
  153.     IE_TO_FRONT
  154.     LAST_ERROR
  155.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  156. end
  157.  
  158. return '<ERROR>'
  159.